#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "Image.h"
#include "QImage"
#include<iostream>
using namespace std;
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    QString filename;
    filename=QFileDialog::getOpenFileName(this,
                                        tr("选择图像"),
                                        "",
                                        tr("Images (*.png *.bmp *.jpg *.tif *.GIF )"));//可打开的文件类型
    if(!filename.isEmpty())
    {
        QImage* img=new QImage;
        if(! ( img->load(filename) ) ) //加载图像
            {
                QMessageBox::information(this,
                                         tr("打开图像失败"),
                                         tr("打开图像失败!"));
                delete img;
            }
        ui->label->setPixmap(QPixmap::fromImage(*img));
    }

}

void MainWindow::on_pushButton_2_clicked()
{

}
